/*
 * jppruebaAsistencia.java
 *
 * Created on 25 de agosto de 2007, 0:24
 */

package Control;
import legajopersonal.*;
/**
 *
 * @author  Administrador
 */
public class jPpruebaAsistencia extends jPTabla{    
    javax.swing.JComboBox combo;
    boolean hace=false,primera=false;
    String valores[][],busca[];
    int cuenta=0;
    /** Creates new form JDllenarsueldo */
    public jPpruebaAsistencia() {
        initComponents();        
    }
    public void ver(String consulta){
        busca=new String[2];
        String [][]datos;
        try{ 
            datos = this.getCliRMI().getObjetoCLIRMI().getTabla(consulta,this.getID());
        }catch(Exception e){
            
        }
        llenar_combo(this.tabla,this.tabla.getColumnModel().getColumn(0)); 
    }
    void hacer(java.awt.event.ItemEvent ev){                 
        int n = this.tabla.getSelectedRow();        
      try{
          String bb=combo.getSelectedItem().toString();
          bb=bb.trim();
          //System.out.println(bb);
          busca=busca_arreglo(bb);
          this.tabla.setValueAt(busca[0],n,1);
          this.tabla.setValueAt(busca[1],n,2);
       }catch(Exception e){}
    }
    
    String[] busca_arreglo(String abc){
        String ret[]=new String[2];
        ret[0]="";
        ret[1]="";
        for(int i=0;i<valores.length;i++){
            if(valores[i][0].equalsIgnoreCase(abc))
            {   ret[0]=valores[i][1];
                ret[1]=valores[i][2];
                break;
            }
        }
        return ret;
    }
    void llenar_combo(javax.swing.JTable tabla,javax.swing.table.TableColumn columna){
        String[][]datos = null;
        try{
            datos = this.getCliRMI().getObjetoCLIRMI().getTabla("select id_concepto," +
                    " id_tipo_concepto,descripcion_corta " +
                    " from conceptos " ,this.getID());            
        }catch(Exception e){
            
        }       
       combo=new javax.swing.JComboBox();       
        combo.setMaximumRowCount(10);
        combo.addItemListener((new java.awt.event.ItemListener(){
        	public void itemStateChanged(java.awt.event.ItemEvent ev){
        		hacer(ev);
        	}
        }));
        try{
            valores = datos;
            for(int i=0;i<datos.length;i++){
                combo.addItem(datos[i][0]);            
            }
        }catch(Exception e){}
        columna.setCellEditor(new javax.swing.DefaultCellEditor(combo));
        javax.swing.table.DefaultTableCellRenderer renderer =
                new javax.swing.table.DefaultTableCellRenderer();
        renderer.setToolTipText("hacer click para ver codigo");
        columna.setCellRenderer(renderer);
    }    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panel_Legajo1 = new legajopersonal.Panel_Legajo();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabla = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        txtDNILista = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtNombreLista = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txtCargoLista = new javax.swing.JTextField();
        txtUnidadLista = new javax.swing.JTextField();
        btnNuevo = new javax.swing.JButton();
        btnActualizar = new javax.swing.JButton();
        btnElimminar = new javax.swing.JButton();
        btnImprimir = new javax.swing.JButton();
        btnSalir = new javax.swing.JButton();

        tabla.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tabla);

        jLabel3.setText("Nombre");

        jLabel2.setText("DNI");

        jLabel5.setText("Unidad Organizativa");

        jLabel4.setText("Cargo");

        btnNuevo.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/fife/plaf/Office2003/new.gif"))); // NOI18N
        btnNuevo.setText("Nuevo");
        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoActionPerformed(evt);
            }
        });

        btnActualizar.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnActualizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/fife/plaf/Office2003/replace.gif"))); // NOI18N
        btnActualizar.setText("Actualizar");
        btnActualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnActualizarActionPerformed(evt);
            }
        });

        btnElimminar.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnElimminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/fife/plaf/Office2003/delete.gif"))); // NOI18N
        btnElimminar.setText("Eliminar");
        btnElimminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnElimminarActionPerformed(evt);
            }
        });

        btnImprimir.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnImprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/fife/plaf/Office2003/print.gif"))); // NOI18N
        btnImprimir.setText("Imprimir");
        btnImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnImprimirActionPerformed(evt);
            }
        });

        btnSalir.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/fife/plaf/Office2003/closeall.gif"))); // NOI18N
        btnSalir.setText("Salir");
        btnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panel_Legajo1Layout = new javax.swing.GroupLayout(panel_Legajo1);
        panel_Legajo1.setLayout(panel_Legajo1Layout);
        panel_Legajo1Layout.setHorizontalGroup(
            panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_Legajo1Layout.createSequentialGroup()
                .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel_Legajo1Layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtNombreLista)
                            .addComponent(txtDNILista, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 265, Short.MAX_VALUE)
                        .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5))
                        .addGap(28, 28, 28)
                        .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtUnidadLista)
                            .addComponent(txtCargoLista, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(panel_Legajo1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 657, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel_Legajo1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(btnNuevo)
                        .addGap(12, 12, 12)
                        .addComponent(btnActualizar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnElimminar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnImprimir)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnSalir)
                        .addGap(113, 113, 113)))
                .addContainerGap())
        );
        panel_Legajo1Layout.setVerticalGroup(
            panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_Legajo1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel_Legajo1Layout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(txtCargoLista, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(txtUnidadLista, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(panel_Legajo1Layout.createSequentialGroup()
                            .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txtDNILista, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel2))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txtNombreLista, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(jLabel3)))
                .addGap(14, 14, 14)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(19, 19, 19)
                .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnNuevo)
                    .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnImprimir)
                        .addComponent(btnSalir))
                    .addGroup(panel_Legajo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnActualizar)
                        .addComponent(btnElimminar)))
                .addGap(19, 19, 19))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panel_Legajo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(panel_Legajo1, javax.swing.GroupLayout.PREFERRED_SIZE, 356, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed
// TODO add your handling code here:
        try{
            this.cerrarPadre();
            //this.CerrarConexionRMI();
        }catch(Exception e){
            System.out.println("Error al cerrar conexiones");
        }
        this.botonSalir();
    }//GEN-LAST:event_btnSalirActionPerformed

    private void btnImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImprimirActionPerformed
// TODO add your handling code here:
        try{
            this.tabla.print();
        }catch(Exception e){
            
        }
    }//GEN-LAST:event_btnImprimirActionPerformed

    private void btnElimminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnElimminarActionPerformed
// TODO add your handling code here:
        botonEliminar();
    }//GEN-LAST:event_btnElimminarActionPerformed

    private void btnActualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnActualizarActionPerformed
// TODO add your handling code here:
        botonActualizar();
    }//GEN-LAST:event_btnActualizarActionPerformed

    private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoActionPerformed
// TODO add your handling code here:
        botonNuevo();
    }//GEN-LAST:event_btnNuevoActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnActualizar;
    private javax.swing.JButton btnElimminar;
    private javax.swing.JButton btnImprimir;
    private javax.swing.JButton btnNuevo;
    private javax.swing.JButton btnSalir;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private legajopersonal.Panel_Legajo panel_Legajo1;
    private javax.swing.JTable tabla;
    private javax.swing.JTextField txtCargoLista;
    private javax.swing.JTextField txtDNILista;
    private javax.swing.JTextField txtNombreLista;
    private javax.swing.JTextField txtUnidadLista;
    // End of variables declaration//GEN-END:variables
    
}
